package demo10;

import java.util.Objects;

public class Studnet implements Comparable<Studnet> {
    public  String name;
    public int score;

    public Studnet(String name, int score) {
        this.name = name;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Studnet{" +
                "name='" + name + '\'' +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(Studnet o) {
//        if(this.score>o.score){
//            return 1;
//        }else if(this.score==o.score){
//            return 0;
//        }else {
//            return -1;
//        }
//    }
        return this.score - o.score;
    }
@Override
    public boolean equals(Object o){
        if(this == o)return true ;
        if(o==null||getClass() !=o.getClass())return false;
        Studnet student = (Studnet)o;
        return score== student.score && Objects.equals(name,student.name);
}
    @Override
    public int hashCode() {
        return Objects.hash(name,score);
    }
}

